package com.example.neteaseplay;

import com.example.neteaseplay.PlayMode.PlayModeChange;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;

public class MainActivity extends Activity implements OnClickListener, PlayModeChange {

    private ImageView mIvPlay;
    private PlayMode mPlayMode;

    private void bindViews() {

        mIvPlay = (ImageView) findViewById(R.id.ivPlay);
        mIvPlay.setOnClickListener(this);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        bindViews();
        initData();
    }

    private void initData() {
        mPlayMode = new PlayMode();
        mPlayMode.setPlayModeChange(this);
        mPlayMode.init();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        switch (v.getId()) {
        case R.id.ivPlay:
            mPlayMode.toggleMode();
            break;

        default:
            break;
        }
    }

    @Override
    public void modeChange(int mode) {
        // TODO Auto-generated method stub
        if(mode == PlayMode.MODE_INIT || mode == PlayMode.MODE_PAUSE) {
            mIvPlay.setBackgroundResource(R.drawable.play_fm_btn_pause_prs);
            pasueMusic();
        }else if(mode == PlayMode.MODE_PLAYING) {
            mIvPlay.setBackgroundResource(R.drawable.play_fm_btn_play_prs);
            playMusic();
        }
    }

    private void playMusic() {
        // TODO Auto-generated method stub
        
    }

    private void pasueMusic() {
        // TODO Auto-generated method stub
        
    }

    
}
